var t, e = require("../../../@babel/runtime/helpers/typeof"), a = require("../../../@babel/runtime/helpers/defineProperty"), s = getApp();

Page({
    data: {
        activeName: "",
        step: 1,
        checkboxGroup: [],
        protocolShow: !1,
        agreement: {},
        form: {
            name: "",
            id_no: "",
            tel: "",
            face_auth_mode: ""
        },
        authcode: "",
        bank_no: "",
        flow_id: "",
        count: "",
        timer: null
    },
    onLoad: function(e) {
        t = this, this.getPersonData();
    },
    onReady: function() {},
    getPersonData: function() {
        var e = s.getNetAddresss("plugin.shop-esign.frontend.person.check-person-approve");
        s._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 === a.result ? (t.setData({
                    person: a.data
                }), "SUCCESS" == a.status && wx.navigateTo({
                    url: "/packageH/signIndexPlu/identifyResult/identifyResult?show=person"
                })) : console.log(a.msg);
            },
            fail: function(t) {
                console.log(t, "失败-----------");
            }
        });
    },
    getAgreement: function() {
        var e = s.getNetAddresss("plugin.yun-sign.frontend.person.get-agreement");
        s._postNetWork({
            url: e,
            showToastIn: !0,
            success: function(e) {
                var a = e.data;
                1 === a.result ? t.setData({
                    agreement: a.data
                }) : s.tips(a.msg);
            }
        });
    },
    getMemberData: function() {
        t.setData({
            step: 2
        });
    },
    toStep: function() {
        this.data.form.name ? this.data.form.id_no ? this.data.form.tel ? this.data.activeName ? t.setData({
            step: 3
        }) : s.tips("请先选择认证方式") : s.tips("请先填写手机号") : s.tips("请先填写身份证号") : s.tips("请先填写姓名");
    },
    checkPersonData: function() {
        var e = s.getNetAddresss("plugin.yun-sign.frontend.person.check-person-approve-by-idNo");
        s._getNetWork({
            url: e,
            showToastIn: !0,
            data: {
                name: t.data.form.name,
                idNo: t.data.form.id_no,
                tel: t.data.form.tel
            },
            success: function(e) {
                if (1 === e.data.result) {
                    var a = e.data;
                    t.setData({
                        person: a.data
                    }), 99 == a.data.status_code ? wx.showModal({
                        title: "提示",
                        content: "您在认证中心已经完成认证，无需重复认证",
                        showCancel: !1,
                        success: function() {
                            wx.navigateTo({
                                url: "/packageH/signIndexPlu/identifyResult/identifyResult?show=person"
                            });
                        }
                    }) : t.setData({
                        step: 3
                    });
                } else wx.showModal({
                    content: e.data.msg,
                    showCancel: !1
                });
            },
            fail: function(t) {
                console.log(t, "失败-----------");
            }
        });
    },
    sureIdentify: function() {
        if (2 != this.data.activeName || this.data.bank_no) {
            var e = "", o = {};
            1 == this.data.activeName ? (e = s.getNetAddresss("plugin.shop-esign.frontend.person.auth-tel-v2"), 
            o = this.data.form) : 2 == this.data.activeName && (e = s.getNetAddresss("plugin.shop-esign.frontend.person.auth-bank-card-v2"), 
            this.setData(a({}, "form.bank_no", this.data.bank_no)), o = this.data.form), s._postNetWork({
                url: e,
                data: o,
                success: function(e) {
                    if (t.data.timer = null, 1 === e.data.result) {
                        var a = e.data;
                        s.tips("已发送"), t.setData({
                            flow_id: a.data.flow_id
                        }), t.data.timer || (t.countDown = 60, t.data.timer = setInterval(function() {
                            t.countDown > 0 && t.countDown <= 60 ? t.setData({
                                count: --t.countDown
                            }) : (clearInterval(t.data.timer), t.data.timer = null);
                        }, 1e3));
                    } else wx.showModal({
                        title: "提示",
                        content: e.data.msg,
                        showCancel: !1
                    });
                }
            });
        } else s.tips("请先填写银行卡");
    },
    sendCode: function() {
        if (2 != this.data.activeName || this.data.bank_no) if (3 == this.data.activeName || this.data.flow_id) {
            if (console.log(this.data.authcode), 3 == this.data.activeName || this.data.authcode) return 3 != this.data.activeName || this.data.form.face_auth_mode ? void this.sendAuthRequest() : (console.log(e(this.data.activeName), this.data.form), 
            void s.tips("请先选择识别方式"));
            s.tips("请先填写验证码");
        } else s.tips("请先获取验证码"); else s.tips("请先填写银行卡");
    },
    sendAuthRequest: function() {
        var e = "", a = {};
        1 == this.data.activeName ? (e = s.getNetAddresss("plugin.shop-esign.frontend.person.check-tel-sms-code"), 
        a = {
            flow_id: this.data.flow_id,
            authcode: this.data.authcode
        }) : 2 == this.data.activeName ? (e = s.getNetAddresss("plugin.shop-esign.frontend.person.check-bank-sms-code"), 
        a = {
            flow_id: this.data.flow_id,
            authcode: this.data.authcode
        }) : (e = s.getNetAddresss("plugin.shop-esign.frontend.person.auth-face"), a = {
            name: this.data.form.name,
            id_no: this.data.form.id_no,
            tel: this.data.form.tel,
            face_auth_mode: this.data.form.face_auth_mode,
            callback_url: ""
        }), s._postNetWork({
            url: e,
            data: a,
            success: function(e) {
                var a = e.data;
                1 === a.result ? 3 == t.data.activeName ? wx.redirectTo({
                    url: "/packageH/signIndexPlu/signPage?url=".concat(a.data.data.authUrl)
                }) : (s.tips(a.msg), 1 == a.data.auth_company ? wx.redirectTo({
                    url: "/packageH/signIndexPlu/identifyResult/identifyResult?show=person&auth_company=1"
                }) : wx.redirectTo({
                    url: "/packageH/signIndexPlu/identifyResult/identifyResult?show=person"
                })) : wx.showModal({
                    title: "提示",
                    content: e.data.msg,
                    showCancel: !1
                });
            },
            fail: function(t) {
                s.tips(t.msg);
            }
        });
    },
    onAgree: function(t) {
        this.setData({
            checkboxGroup: t.detail
        });
    },
    showProtocol: function() {
        this.setData({
            protocolShow: !0
        });
    },
    closePopup: function() {
        console.log(this.data.checkboxGroup), this.setData({
            protocolShow: !1
        });
    },
    handlerInput: function(t) {
        var e = t.target.dataset.type;
        this.setData(a({}, "".concat(e), t.detail));
    },
    onHide: function() {
        clearInterval(this.data.timer);
    }
});